package cc.uncarbon.module.appapi.web.app;


import cc.uncarbon.framework.web.model.response.ApiResult;
import cc.uncarbon.module.appapi.constant.AppApiConstant;

import cc.uncarbon.module.appapi.model.request.BookCategoryInsertOrUpdateDTO;
import cc.uncarbon.module.appapi.model.request.BookOrderInsertOrUpdateDTO;
import cc.uncarbon.module.appapi.service.BookCategoryService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;



@Tag(name = "记账分类接口")
@RequestMapping(AppApiConstant.HTTP_API_URL_PREFIX + "/api/v1")
@RequiredArgsConstructor
@RestController
@Slf4j
public class HOSBookCategoryController {
private final BookCategoryService bookCategoryService;
    @Operation(summary = "记账类别新增")
    @PostMapping("/book/category/create")
    public ApiResult BookCategoryCreate(@RequestBody @Validated BookCategoryInsertOrUpdateDTO dto){
        Long id = bookCategoryService.create(dto);
        return ApiResult.data( id);
    }
    @Operation(summary = "记账类别列表")
    @GetMapping("/book/category/list")
    public ApiResult BookCategoryList(){
        return ApiResult.data( bookCategoryService.getBookCategoryList());
    }
    @Operation(summary = "记账类别修改")
    @PostMapping("/book/category/updata")
    public ApiResult BookCategoryUpdata(@RequestBody @Validated BookCategoryInsertOrUpdateDTO dto){
        Long id = bookCategoryService.updata(dto);
        return ApiResult.data( id);
    }
}
